package com.test.kupi.fw;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ApplicationManager {
	
	public static WebDriver driver;
	public static String baseUrl;

	private NavHelper navHelper;
	private SearchHelper searchHelper;
	private LoginHelper loginHelper;
	private BasketHelper basketHelper;
	
	public ApplicationManager() {
	    driver = new FirefoxDriver();
	    baseUrl = "http://kupi.tut.by/";
	    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}

	public void stop() {
	    driver.quit();
	}
	
	public NavHelper getNavHelper() {
		if (navHelper == null) {
			navHelper = new NavHelper(this);
		}
		return navHelper;
	}
	
	public SearchHelper getSearchHelper() {
		if (searchHelper == null) {
			searchHelper = new SearchHelper(this);
		}
		return searchHelper;
	}
	
	public LoginHelper getLoginHelper() {
		if (loginHelper == null) {
			loginHelper = new LoginHelper(this);
		}
		return loginHelper;
	}
	
	public BasketHelper getBasketHelper() {
		if (basketHelper == null) {
			basketHelper = new BasketHelper(this);
		}
		return basketHelper;
	}
	
}
